package a2022.a20220914;

import java.math.BigDecimal;
import java.util.Arrays;

/**
 * @author lenovo
 * @date 2022/9/14
 */
public class a {
    public static void main(String[] args) {
        System.out.println(trimMean(new int[]{
                9,7,8,7,7,8,4,4,6,8,8,7,6,8,8,9,2,6,0,0,1,10,8,6,3,3,5,1,10,9,0,7,10,0,10,4,1,10,6,9,3,6,0,0,2,7,0,6,7,2,9,7,7,3,0,1,6,1,10,3}));
    }

    public static double trimMean(int[] arr) {
        Arrays.sort(arr);
        int len = arr.length;
        double sum = 0;
        int num = (int) (len * 0.05);
        for (int i = num; i < len - num; i++) {
            sum += arr[i];
        }
        sum = sum / (len - num - num);

        BigDecimal valueDecimal = new BigDecimal(sum);
        double value = valueDecimal.setScale(5, BigDecimal.ROUND_HALF_UP).doubleValue();
        return value;
    }
}
